{
 "cells": [
  {
   "cell_type": "markdown",
   "source": [
    "### if 条件"
   ],
   "metadata": {
    "collapsed": false
   }
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "可以参军\n"
     ]
    }
   ],
   "source": [
    "# 简单if\n",
    "# 修改 age（年龄）和 gender（性别）两个条件测试下面代码\n",
    "age = 19\n",
    "gender = 'male'\n",
    "\n",
    "if age > 18 and gender == 'male':\n",
    "    print('可以参军')\n",
    "else:\n",
    "    print('不可以参军')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "不可以参军\n"
     ]
    }
   ],
   "source": [
    "# 嵌套if\n",
    "# 修改 age（年龄）和 gender（性别）两个条件测试下面代码\n",
    "age = 70\n",
    "gender = 'male'\n",
    "\n",
    "if age > 18 and gender == 'male':\n",
    "    if age > 65:\n",
    "        print('不可以参军')\n",
    "    else:\n",
    "        print('可以参军')\n",
    "else:\n",
    "    print('不可以参军')"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "天气不错\n"
     ]
    }
   ],
   "source": [
    "# 多个if条件并列\n",
    "temp = 22\n",
    "\n",
    "if temp < 5:\n",
    "    print(\"天气很冷，注意保暖\")\n",
    "elif temp < 15:\n",
    "    print(\"天气有点冷\")\n",
    "elif temp < 25:\n",
    "    print(\"天气不错\")\n",
    "else:\n",
    "    print(\"天气有点热\")"
   ],
   "metadata": {
    "collapsed": false,
    "pycharm": {
     "name": "#%%\n"
    }
   }
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}